unit dbcMsgMngr;
// Database Comparer VCL v.3.0
// Copyright (C) 1998-2006, by Boris Loboda
// www.CleverComponents.com
{$I Comparer.INC}

interface
  Uses Classes, Contnrs;

type

  TMsgType = (mt_Inf, mt_Wrn, mt_Err);
  TMsgSetType = set of TMsgType;

  TMsgData = class
  public
    Msg: String;        // message text
    MsgType: TMsgType;  // message type
    FileName: String;   // file name (source text parsing)
    PosX: integer;      // char position
    PosY: Integer;      // line in source text
    Obj: TObject;
    procedure Assign(Source: TMsgData);
  end;

  PMsgData = ^TMsgData;

  TMsgManager = class
  protected
    fMessages: TObjectList;
    function GetIsErr(): Boolean;
    function GetIsWrn(): Boolean;
    function GetIsInf(): Boolean;
    function GetIsMsg(): Boolean; overload;
    function Get_IsMsg(aMsgType: TMsgType): Boolean;
    function Get_MsgCount(aMsg: TMsgSetType): Integer;
    function GetMsgCount(): Integer;
    function GetErrCount(): Integer;
    function GetWrnCount(): Integer;
    function GetInfCount(): Integer;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Clear;
    procedure AddMsg(aMsg: String; aMsgType: TMsgType = mt_Err; aObj: TObject = nil);
    procedure AddScriptMsg(aMsg: String; aFileName: String; aPosX, aPosY: integer; aMsgType: TMsgType = mt_Err);
    procedure AddObjMsg(aMsg: String; aObj: TObject; aPosX, aPosY: Integer; aMsgType: TMsgType = mt_Err);
    procedure CopyFrom(aMsgMngr: TMsgManager);
    function ErrSummary(): String;
    property Messages: TObjectList read fMessages;
    property IsErr: Boolean read GetIsErr;
    property IsWrn: Boolean read GetIsWrn;
    property IsInf: Boolean read GetIsInf;
    property IsMsg: Boolean read GetIsMsg;
    property ErrCount: Integer read GetErrCount;
    property WrnCount: Integer read GetWrnCount;
    property InfCount: Integer read GetInfCount;
    property MsgCount: Integer read GetMsgCount;
  end;

implementation

//The full source code is available on purchasing the product

end.
